package com.wx.references;

import lombok.extern.slf4j.Slf4j;

import java.lang.ref.WeakReference;

/**
 * 弱引用
 * @description:
 * @author: wangxun
 * @createDate: 2021/12/31
 * @version: 1.0
 */
@Slf4j
public class WeakReferences {
    public static void main(String[] args) {
        WeakReference<Worker> weakReference = new WeakReference<>(new Worker());

        log.info("worker:{}",weakReference.get());
        // 手动调用gc
        System.gc();
        log.info("worker:{}",weakReference.get());
    }
}
